package com.icongyou.enterprise.talent_analysis.scheduler;

import com.icongyou.enterprise.talent_analysis.mapper.AIInsightCacheMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 缓存清理定时任务
 * 定期清理过期的AI洞察缓存
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class CacheCleanupScheduler {
    
    private final AIInsightCacheMapper aiInsightCacheMapper;
    
    /**
     * 每天凌晨3点清理过期的AI洞察缓存
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void cleanupExpiredAIInsightCache() {
        
        try {
            int deleted = aiInsightCacheMapper.deleteExpired();
        } catch (Exception e) {
        }
    }
}
